package com.xmkj.bearuser.jifen;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.common.retrofit.method.JiFenShopListEntity;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;
import com.xmkj.bearuser.TempItemBean;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/5/4
 * 描述：
 */

public class JiFenSonAdapter extends CommonAdapter<JiFenShopListEntity.ListsEntity> {
    int type ;
    public JiFenSonAdapter(Context context, List<JiFenShopListEntity.ListsEntity> data , int position) {
        super(context, data);
        this.type = position;
    }

    @Override
    protected void convert(ViewHolder holder, final JiFenShopListEntity.ListsEntity item, int position) {


        holder.getParentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext,AwardDelActivity.class);
                TempItemBean tempItemBean = new TempItemBean() ;
                tempItemBean.fvid = item.fvid;
                tempItemBean.gid = item.gid+"" ;
                tempItemBean.vid = item.vid ;
                tempItemBean.roomIds = item.roomIds ;
                intent.putExtra(AwardDelActivity.TEMPBEAN,tempItemBean);
                mContext.startActivity(intent);

            }
        });
        holder.setImageStr(R.id.iv_img,item.goodsthumb);
        holder.setText(R.id.tv_brand,item.goodsname);
        TextView tvRate = holder.getView(R.id.tv_rate);

        SpannableString spannableString = new SpannableString("开奖进度"+" "+(int)(item.openratio*100*1.0)+"%");
        spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0E41")), 4,spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tvRate.setText(spannableString);
        ProgressBar progressBar = holder.getView(R.id.progress);
        progressBar.setSecondaryProgress((int)(item.openratio*100*1.0));





    }

    @Override
    protected int getItemViewLayoutId(int position, JiFenShopListEntity.ListsEntity item) {
        return R.layout.item_jifen;
    }
}
